Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Session triggers
In addition to defining schema trigger procedures that are always executed when an operation occurs on a table, you can also define trigger blocks within your application that act on these events, much as you can define triggers for user interface events. These triggers are not of great utility, but there may be circumstances where you need the same block of code to execute regardless of which of a number of different update or find statements against a table are executed in a portion of your application.
A session trigger is in scope while the procedure that defines it is running. The code in the trigger executes in the context of the procedure that defines it, regardless of where the event occurs that fires the trigger. Therefore, it can access local variables and other procedure objects not available to the procedure where the event occurs.
The syntax for session triggers is modeled on the syntax for user interface events:
The
eventcan beCREATE,WRITE,DELETE,FIND, orASSIGN, as for schema triggers.The
objectis a database table name in the case ofCREATE,DELETE,FIND, andWRITEtriggers, or a database field qualified by its table name for theASSIGNtrigger.The
reference-clauseapplies only to theWRITEandASSIGNtriggers. For theWRITEtrigger it is:
For the
ASSIGNtrigger it is:
If you include the
OVERRIDEoption, then this trigger block executes in place of any schema trigger for the same event and object. This is allowed only if you checked on the Overridable toggle box when you defined the schema trigger in the Data Dictionary. Otherwise, an error results when the trigger block is executed.The
trigger-blockis a single statement orDO ENDblock just as for user interface triggers. The trigger block executes as would a call to an internal procedure in the same place in the code.If Progress encounters an additional session trigger for an event and object when a trigger is still in scope for that combination, the new one replaces the old one for the duration of the new trigger’s scope. Alternatively, if you use the
REVERToption in a session trigger block, the current session trigger for the event and object is cancelled and the previously executed session trigger definition is reactivated. If there is no other session trigger on the stack, then the session trigger is deactivated altogether.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |